/**
 * This is a generated class and is not intended for modification.  To customize behavior
 * of this value object you may modify the generated sub-class of this class - ProductoDTO.as.
 */

package valueObjects
{
import com.adobe.fiber.services.IFiberManagingService;
import com.adobe.fiber.util.FiberUtils;
import com.adobe.fiber.valueobjects.IValueObject;
import flash.events.Event;
import flash.events.EventDispatcher;
import mx.binding.utils.ChangeWatcher;
import mx.collections.ArrayCollection;
import mx.events.PropertyChangeEvent;
import mx.validators.ValidationResult;

import flash.net.registerClassAlias;
import flash.net.getClassByAlias;
import com.adobe.fiber.core.model_internal;
import com.adobe.fiber.valueobjects.IPropertyIterator;
import com.adobe.fiber.valueobjects.AvailablePropertyIterator;

use namespace model_internal;

[ExcludeClass]
public class _Super_ProductoDTO extends flash.events.EventDispatcher implements com.adobe.fiber.valueobjects.IValueObject
{
    model_internal static function initRemoteClassAliasSingle(cz:Class) : void
    {
        try
        {
            if (flash.net.getClassByAlias("com.rec.dto.ProductoDTO") == null)
            {
                flash.net.registerClassAlias("com.rec.dto.ProductoDTO", cz);
            }
        }
        catch (e:Error)
        {
            flash.net.registerClassAlias("com.rec.dto.ProductoDTO", cz);
        }
    }

    model_internal static function initRemoteClassAliasAllRelated() : void
    {
    }

    model_internal var _dminternal_model : _ProductoDTOEntityMetadata;
    model_internal var _changedObjects:mx.collections.ArrayCollection = new ArrayCollection();

    public function getChangedObjects() : Array
    {
        _changedObjects.addItemAt(this,0);
        return _changedObjects.source;
    }

    public function clearChangedObjects() : void
    {
        _changedObjects.removeAll();
    }

    /**
     * properties
     */
    private var _internal_id_tipo_producto : String;
    private var _internal_preciolista : Object;
    private var _internal_str_codigo : Object;
    private var _internal_id_producto : Object;
    private var _internal_str_descripcion : String;

    private static var emptyArray:Array = new Array();


    /**
     * derived property cache initialization
     */
    model_internal var _cacheInitialized_isValid:Boolean = false;

    model_internal var _changeWatcherArray:Array = new Array();

    public function _Super_ProductoDTO()
    {
        _model = new _ProductoDTOEntityMetadata(this);

        // Bind to own data or source properties for cache invalidation triggering
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "id_tipo_producto", model_internal::setterListenerId_tipo_producto));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "preciolista", model_internal::setterListenerPreciolista));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "str_codigo", model_internal::setterListenerStr_codigo));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "id_producto", model_internal::setterListenerId_producto));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "str_descripcion", model_internal::setterListenerStr_descripcion));

    }

    /**
     * data/source property getters
     */

    [Bindable(event="propertyChange")]
    public function get id_tipo_producto() : String
    {
        return _internal_id_tipo_producto;
    }

    [Bindable(event="propertyChange")]
    public function get preciolista() : Object
    {
        return _internal_preciolista;
    }

    [Bindable(event="propertyChange")]
    public function get str_codigo() : Object
    {
        return _internal_str_codigo;
    }

    [Bindable(event="propertyChange")]
    public function get id_producto() : Object
    {
        return _internal_id_producto;
    }

    [Bindable(event="propertyChange")]
    public function get str_descripcion() : String
    {
        return _internal_str_descripcion;
    }

    public function clearAssociations() : void
    {
    }

    /**
     * data/source property setters
     */

    public function set id_tipo_producto(value:String) : void
    {
        var oldValue:String = _internal_id_tipo_producto;
        if (oldValue !== value)
        {
            _internal_id_tipo_producto = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "id_tipo_producto", oldValue, _internal_id_tipo_producto));
        }
    }

    public function set preciolista(value:Object) : void
    {
        var oldValue:Object = _internal_preciolista;
        if (oldValue !== value)
        {
            _internal_preciolista = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "preciolista", oldValue, _internal_preciolista));
        }
    }

    public function set str_codigo(value:Object) : void
    {
        var oldValue:Object = _internal_str_codigo;
        if (oldValue !== value)
        {
            _internal_str_codigo = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "str_codigo", oldValue, _internal_str_codigo));
        }
    }

    public function set id_producto(value:Object) : void
    {
        var oldValue:Object = _internal_id_producto;
        if (oldValue !== value)
        {
            _internal_id_producto = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "id_producto", oldValue, _internal_id_producto));
        }
    }

    public function set str_descripcion(value:String) : void
    {
        var oldValue:String = _internal_str_descripcion;
        if (oldValue !== value)
        {
            _internal_str_descripcion = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "str_descripcion", oldValue, _internal_str_descripcion));
        }
    }

    /**
     * Data/source property setter listeners
     *
     * Each data property whose value affects other properties or the validity of the entity
     * needs to invalidate all previously calculated artifacts. These include:
     *  - any derived properties or constraints that reference the given data property.
     *  - any availability guards (variant expressions) that reference the given data property.
     *  - any style validations, message tokens or guards that reference the given data property.
     *  - the validity of the property (and the containing entity) if the given data property has a length restriction.
     *  - the validity of the property (and the containing entity) if the given data property is required.
     */

    model_internal function setterListenerId_tipo_producto(value:flash.events.Event):void
    {
        _model.invalidateDependentOnId_tipo_producto();
    }

    model_internal function setterListenerPreciolista(value:flash.events.Event):void
    {
        _model.invalidateDependentOnPreciolista();
    }

    model_internal function setterListenerStr_codigo(value:flash.events.Event):void
    {
        _model.invalidateDependentOnStr_codigo();
    }

    model_internal function setterListenerId_producto(value:flash.events.Event):void
    {
        _model.invalidateDependentOnId_producto();
    }

    model_internal function setterListenerStr_descripcion(value:flash.events.Event):void
    {
        _model.invalidateDependentOnStr_descripcion();
    }


    /**
     * valid related derived properties
     */
    model_internal var _isValid : Boolean;
    model_internal var _invalidConstraints:Array = new Array();
    model_internal var _validationFailureMessages:Array = new Array();

    /**
     * derived property calculators
     */

    /**
     * isValid calculator
     */
    model_internal function calculateIsValid():Boolean
    {
        var violatedConsts:Array = new Array();
        var validationFailureMessages:Array = new Array();

        var propertyValidity:Boolean = true;
        if (!_model.id_tipo_productoIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_id_tipo_productoValidationFailureMessages);
        }
        if (!_model.preciolistaIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_preciolistaValidationFailureMessages);
        }
        if (!_model.str_codigoIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_str_codigoValidationFailureMessages);
        }
        if (!_model.id_productoIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_id_productoValidationFailureMessages);
        }
        if (!_model.str_descripcionIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_str_descripcionValidationFailureMessages);
        }

        model_internal::_cacheInitialized_isValid = true;
        model_internal::invalidConstraints_der = violatedConsts;
        model_internal::validationFailureMessages_der = validationFailureMessages;
        return violatedConsts.length == 0 && propertyValidity;
    }

    /**
     * derived property setters
     */

    model_internal function set isValid_der(value:Boolean) : void
    {
        var oldValue:Boolean = model_internal::_isValid;
        if (oldValue !== value)
        {
            model_internal::_isValid = value;
            _model.model_internal::fireChangeEvent("isValid", oldValue, model_internal::_isValid);
        }
    }

    /**
     * derived property getters
     */

    [Transient]
    [Bindable(event="propertyChange")]
    public function get _model() : _ProductoDTOEntityMetadata
    {
        return model_internal::_dminternal_model;
    }

    public function set _model(value : _ProductoDTOEntityMetadata) : void
    {
        var oldValue : _ProductoDTOEntityMetadata = model_internal::_dminternal_model;
        if (oldValue !== value)
        {
            model_internal::_dminternal_model = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "_model", oldValue, model_internal::_dminternal_model));
        }
    }

    /**
     * methods
     */


    /**
     *  services
     */
    private var _managingService:com.adobe.fiber.services.IFiberManagingService;

    public function set managingService(managingService:com.adobe.fiber.services.IFiberManagingService):void
    {
        _managingService = managingService;
    }

    model_internal function set invalidConstraints_der(value:Array) : void
    {
        var oldValue:Array = model_internal::_invalidConstraints;
        // avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_invalidConstraints = value;
            _model.model_internal::fireChangeEvent("invalidConstraints", oldValue, model_internal::_invalidConstraints);
        }
    }

    model_internal function set validationFailureMessages_der(value:Array) : void
    {
        var oldValue:Array = model_internal::_validationFailureMessages;
        // avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_validationFailureMessages = value;
            _model.model_internal::fireChangeEvent("validationFailureMessages", oldValue, model_internal::_validationFailureMessages);
        }
    }

    model_internal var _doValidationCacheOfId_tipo_producto : Array = null;
    model_internal var _doValidationLastValOfId_tipo_producto : String;

    model_internal function _doValidationForId_tipo_producto(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfId_tipo_producto != null && model_internal::_doValidationLastValOfId_tipo_producto == value)
           return model_internal::_doValidationCacheOfId_tipo_producto ;

        _model.model_internal::_id_tipo_productoIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isId_tipo_productoAvailable && _internal_id_tipo_producto == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "id_tipo_producto is required"));
        }

        model_internal::_doValidationCacheOfId_tipo_producto = validationFailures;
        model_internal::_doValidationLastValOfId_tipo_producto = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfPreciolista : Array = null;
    model_internal var _doValidationLastValOfPreciolista : Object;

    model_internal function _doValidationForPreciolista(valueIn:Object):Array
    {
        var value : Object = valueIn as Object;

        if (model_internal::_doValidationCacheOfPreciolista != null && model_internal::_doValidationLastValOfPreciolista == value)
           return model_internal::_doValidationCacheOfPreciolista ;

        _model.model_internal::_preciolistaIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isPreciolistaAvailable && _internal_preciolista == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "preciolista is required"));
        }

        model_internal::_doValidationCacheOfPreciolista = validationFailures;
        model_internal::_doValidationLastValOfPreciolista = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfStr_codigo : Array = null;
    model_internal var _doValidationLastValOfStr_codigo : Object;

    model_internal function _doValidationForStr_codigo(valueIn:Object):Array
    {
        var value : Object = valueIn as Object;

        if (model_internal::_doValidationCacheOfStr_codigo != null && model_internal::_doValidationLastValOfStr_codigo == value)
           return model_internal::_doValidationCacheOfStr_codigo ;

        _model.model_internal::_str_codigoIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isStr_codigoAvailable && _internal_str_codigo == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "str_codigo is required"));
        }

        model_internal::_doValidationCacheOfStr_codigo = validationFailures;
        model_internal::_doValidationLastValOfStr_codigo = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfId_producto : Array = null;
    model_internal var _doValidationLastValOfId_producto : Object;

    model_internal function _doValidationForId_producto(valueIn:Object):Array
    {
        var value : Object = valueIn as Object;

        if (model_internal::_doValidationCacheOfId_producto != null && model_internal::_doValidationLastValOfId_producto == value)
           return model_internal::_doValidationCacheOfId_producto ;

        _model.model_internal::_id_productoIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isId_productoAvailable && _internal_id_producto == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "id_producto is required"));
        }

        model_internal::_doValidationCacheOfId_producto = validationFailures;
        model_internal::_doValidationLastValOfId_producto = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfStr_descripcion : Array = null;
    model_internal var _doValidationLastValOfStr_descripcion : String;

    model_internal function _doValidationForStr_descripcion(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfStr_descripcion != null && model_internal::_doValidationLastValOfStr_descripcion == value)
           return model_internal::_doValidationCacheOfStr_descripcion ;

        _model.model_internal::_str_descripcionIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isStr_descripcionAvailable && _internal_str_descripcion == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "str_descripcion is required"));
        }

        model_internal::_doValidationCacheOfStr_descripcion = validationFailures;
        model_internal::_doValidationLastValOfStr_descripcion = value;

        return validationFailures;
    }
    

}

}
